<!-- /* Description for file.
 * 资源定制（设施定制）
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/resources
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    张海杰2011年0624
 * @lastmodified  张海杰2011年0624
 */
 -->
<?php
echo $html->css ( 'jquery-validate/css/screen' );
echo $html->css ( 'tab' );
echo $javascript->link ( 'checkedAll' );
?>
<script type="text/javascript">
	function getDelStr() {
		var delArr = $("#ResourceSelectResourcesForm :checkbox:checked");
		if(delArr.length==0)
		{
			alert("请选择你要删除的项!");
			return;
		}
		if(!confirm("确定删除?"))
		{
			return;
		}
		var str = "";
		for(var i=0;i<delArr.length;i++) {
			var del = delArr[i].value;
			str += del;
			str += "/";
		}
		$("#delStr").val(str);
		$("#ResourceDeleteSomeForm").submit();
	} 
	
	//Form验证

	 $(document).ready(function() {
	 	 $.validator.setDefaults({       
	 		 submitHandler: function(form) {    
	 		  form.submit();    
	 		}       
	 	});   
		$("#ResourceAddForm").validate({
			rules: {
				"data[Resource][resourceName]":{
						required: true,alowsome:true,stringMinLength:1,stringMaxLength:50
					},
				"data[Resource][description]":{
						required: false,stringMinLength:1,stringMaxLength:255 
					}
				},
			messages:{},
			//设置验证触发事件 
			focusInvalid: false, 
			onkeyup: false, 
			//设置错误信息提示DOM  
			errorPlacement: function(error, element) { 
			error.appendTo( element.parent()); 
			}
		});
	 });	
	
	// 查询时局部刷新//	
	$(document).ready(function(){
		$("#ResourceOrgans1").change(function(){
			var changeorgansid = $(this).find('option:selected').val();
			if(changeorgansid!=""){
				$("#ResourceOrganId1").val(changeorgansid);
				$("#reloadpart").load('<?php echo ROOT_WEB_PATH; ?>/resources/selectResources/  #reloadpart',
					{ "organid":$('#ResourceOrganId1').val()},
					function(){
						$("#checkedAll").click(function() { 
							if ($(this).attr("checked") == true) { // 全选 
							$("input[name='checkbox_name']").each(function() { 
							$(this).attr("checked", true); 
							}); 
							} else { // 取消全选 
							$("input[name='checkbox_name']").each(function() { 
							$(this).attr("checked", false); 
							}); 
							} 
							});	
						});
			}
			else  {window.location.reload();	}

		});
	});
</script>

<!-- 当前位置-->
<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('Resourcebooksmanage');//一级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('Resources',true));//当前操作地用span加粗?> 						  
		</td>
	</tr>
</table>
</div>
<!-- 当前位置-->
<div class="tabflex">

<?php echo $form->create('Resource',array('action'=>'deleteSome','type'=> 'post'));?>
<?php echo $form->hidden('delStr',array('name'=>'resourcesid','id'=>'delStr'));?>
<?php echo $form->end();?>

<?php echo $form->create('Resource',array('action'=>'add','type'=>'post'));?>
<fieldset><legend><?php __('Resources Add');?></legend>
<table width="100%" cellspacing="0" cellpadding="0" border="0"
	style="text-align: left">
	<tr>
		<td></td>
		<td><?php __('ResourcesName');?>:</td>
		<td colspan="3"><?php echo $form->text('resourceName',array('class' => 'TextBoxH')); ?></td>
	</tr>
	<tr>
		<td width="50"></td>
		<td width="100"><?php __('Resources organs');?>:</td>
<!--所属机构下拉-->
		<td >
		<?php $options = array();
					foreach($organs as $eachrecord)
					{
						$options[$eachrecord['Organ']['id']] = $eachrecord['Organ']['name'];
					}
					echo $form->input('organ_id',array('empty' =>'不限','options'=>$options,'label'=>false,'div'=>false,'class'=>'TextBoxH'));		
				?>
		</td>
		<td width="50"></td>
		<td width="100"><?php __('Status');?>:</td>
<!--当前状态下拉-->
		<td >
		<?php echo $form->input('status',
				array(
				'options'=>array('0'=>'可用','1'=>'不可用'),
				'label'=>false,'div'=>false,'class'=>'TextBoxE1'));		
		?>
		</td>
	</tr>
	<tr>
		<td></td>
		<td><?php __('Resources Description');?>:</td>
		<td colspan="3"><?php echo $form->textarea('description',array('class' => 'TextBoxH','label' => false)); ?></td>
		<td></td>
	
	</tr>
	</table>

		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td width="50px">
				<td width="100px"><?php echo $form->button('增加',array('type'=>'submit','class'=>'newsubmit',"class"=>"btn2"));?></td>
				<td width="100px"><?php echo $form->button('取消',array('type'=>'reset','class'=>'resetsubmit',"class"=>"btn2"));?>
				<!-- __('reset', true)取消--></td>
				<td width="100px">
				<?php echo $form->button('删除',array('type'=>'button','class'=>'deletebutton','onclick'=>'getDelStr()',"class"=>"btn2"));?>
				</td>
				<!--  __('delete', true) 删除、提示 -->
			</tr>
		</table>
</fieldset>
<?php echo $form->end();?>
</div>
<?php echo $form->create('Resource',array('action'=>'selectResources','type'=> 'post'));?>
<!-- 资源定制列表 -->
<div class="tabflex">
<table width="100%" cellspacing="0" cellpadding="0" border="0"
	style="text-align: left">
	<tr>
	<td>
		<?php echo $form->input('organs1',array('options'=>$options,'label'=>false,'div'=>false,'class'=>'TextBoxE1','empty'=>'不限'));		
		?>
	</td>
	<td><?php  echo $form->hidden('organ_id1');?></td>
	</tr>
</table>
</div>
<div id="reloadpart">				
<div id="nav1" style="width:97%">			
<table width="100%" cellpadding="0" cellspacing="0" class="tab1">
	<tr>
		<th width="70px"><?php echo $form->checkbox('',array('id'=>'checkedAll'));?></th>
		<th ><?php echo __('ResourcesName');//设施名称?></th>
		<th ><?php echo __('ResourcesStatus');//不可用?></th>
		<th ><?php echo __('ResourcesDescription');//备注?></th>
		<th width="40px"><?php echo __('Operate');//修改?></th>
	</tr>
	<!-- Here's where we loop through our $Notes array, printing out post info --> 
	
	<?php 
	foreach ($resources as $resource):
	?>
		<tr class=normal onmouseover='this.className= "over " '
			onmouseup='this.className= "over " '
			onmouseout='this.className= "normal " ' id="search">
		<td>
			<!-- 批量删除选择 -->				
			<?php echo $form->checkbox($resource['Resource']['id'], array('value' => $resource['Resource']['id'],'name'=>'checkbox_name'));?>
		</td>
		<td title="<?php echo $resource['Resource']['resourceName']; ?>">
			<?php echo $resource['Resource']['resourceName']; ?>
		</td>
		<td id="status_name">
			<?php 
			$str=$resource['Resource']['status']; 
			if($str=='0'){
				echo '可用';
			}
			else if($str=='1'){
				echo '不可用';
			}
			?>
		</td>
		<td title="<?php echo $resource['Resource']['description']; ?>">
			<?php echo $resource['Resource']['description']; ?>
		</td>
		<td style="display:none"><?php echo $resource['Resource']['organ_id'];?></td>
		<td width="40px">
			<?php echo $html->link( $html->image('edit.gif', array('alt' =>  __('Edit', true),'border'=>'0')), 
			'/resources/edit/' . $resource['Resource']['id'], null,null,array('escape'=>false));  ?> 
				 <!-- __('Edit', true) 修改-->
		</td>
		</tr> 
	<?php endforeach; ?>
</table>
</div>
</div>

<!-- 资源定制列表 -->
<?php echo $form->end();?>


